<html>
<head>
<style>
fieldset
{
    inline-size:200px;
    block-size:100px;
    margin:1em;
    display:inline-block;
}

div
{
    inline-size:100px;
    block-size:25px;
    background-color:orange;
}

</style>
</head>

LTR fieldset with left/center/right text-align: <br>

<fieldset>
<legend style="text-align:left; margin-left:20px"><div></div></legend>
</fieldset>

<fieldset>
<legend style="text-align:right; margin-right:20px"><div></div></legend>
</fieldset>

<fieldset>
<legend style="text-align:center;"><div></div></legend>
</fieldset>

<br>

RTL fieldset with left/center/right text-align: <br>

<fieldset dir=rtl>
<legend style="text-align:left; margin-left:20px"><div></div></legend>
</fieldset>

<fieldset dir=rtl>
<legend style="text-align:right; margin-right:20px"><div></div></legend>
</fieldset>

<fieldset dir=rtl>
<legend style="text-align:center;"><div></div></legend>
</fieldset>

<br>

Vertical LTR fieldset with left/center/right text-align: <br>

<fieldset style="-webkit-writing-mode:vertical-lr">
<legend style="text-align:left; margin-top:20px"><div></div></legend>
</fieldset>

<fieldset style="-webkit-writing-mode:vertical-lr">
<legend style="text-align:right; margin-bottom:20px"><div></div></legend>
</fieldset>

<fieldset style="-webkit-writing-mode:vertical-lr">
<legend style="text-align:center"><div></div></legend>
</fieldset>


<br>

Vertical RTL fieldset with left/center/right text-align: <br>

<fieldset dir=rtl style="-webkit-writing-mode:vertical-lr">
<legend style="text-align:left; margin-top:20px"><div></div></legend>
</fieldset>

<fieldset dir=rtl style="-webkit-writing-mode:vertical-lr">
<legend style="text-align:right; margin-bottom:20px"><div></div></legend>
</fieldset>

<fieldset dir=rtl style="-webkit-writing-mode:vertical-lr">
<legend style="text-align:center"><div></div></legend>
</fieldset>
